﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GalaSoft.MvvmLight;
namespace UI.ViewModel
{
    [PropertyChanged.AddINotifyPropertyChangedInterface]
  public  class CostViewModel:ViewModelBase
    {
        public Model.Rooms CurrRoom { get; set; }
       
        public string MeterType { get; set; }
        public List<Model.F_Water> ListWater { get; set; }
        public Model.F_Water CurrWater { get; set; }


        public Model.F_CostRoom CurrCostRoom { get; set; }

        public List<Model.F_CostRoom> ListCostRoom { get; set; }
        public List<Model.Rooms> ListRoom { get; set; }


        //付款方式列表
        public List<Model.FeeType> ListFeeTypes { get; set; }


        public HandyControl.Controls.Dialog Dialog { get; set; }

        public decimal PayAmount { get; set; }



        public void Query( string buildId,string roomNo,string ownerName)
        {

            var dbContext = new Model.DataContext();
            //先查询RoomID
            var query = dbContext.DB.Queryable<Model.Rooms>();


            if (!string.IsNullOrEmpty(buildId))
            {
                query = query.Where(r => r.BuildingId.ToString() == buildId);
            }

            if (!string.IsNullOrEmpty(roomNo))
            {
                query = query.Where(r => r.No.Contains( roomNo));
            }

            if (!string.IsNullOrEmpty(ownerName))
            {
                query = query.Where(r => r.OwnerName.Contains(ownerName));
            }

            ListRoom = query.ToList();
             
             
        }
    }
}
